//
//  HMTabBarController.m
//  OC版本新浪微博
//
//  Created by 赵少朋赵少朋 on 17/1/18.
//  Copyright © 2017年 ITheima. All rights reserved.
//

#import "HMTabBarController.h"
#import "HMTabBar.h"
#import "HMHomeController.h"
#import "HMMessageController.h"
#import "HMProfileController.h"
#import "HMDiscoverController.h"

@interface HMTabBarController ()

@end

@implementation HMTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    HMTabBar *tabBar = [[HMTabBar alloc] init];
    [self setValue:tabBar forKey:@"tabBar"];
    tabBar.backgroundColor = [UIColor whiteColor];
    
    self.tabBar.tintColor = ThemeColor;
    
    [self settingChildViewController:@"HMHomeController" title:@"首页" imageName:@"tabbar_home"];
    [self settingChildViewController:@"HMMessageController" title:@"消息" imageName:@"tabbar_message_center"];
    [self settingChildViewController:@"HMDiscoverController" title:@"发现" imageName:@"tabbar_discover"];
    [self settingChildViewController:@"HMProfileController" title:@"我的" imageName:@"tabbar_profile"];
    
}

- (void)settingChildViewController:(NSString *)viewCtName title:(NSString *)title imageName:(NSString *)imageName {

    Class Controller = NSClassFromString(viewCtName);
    UIViewController *viewCt = [[Controller alloc] init];
    
    viewCt.title = title;
    viewCt.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    viewCt.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",imageName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UINavigationController *nav  = [[UINavigationController alloc] initWithRootViewController:viewCt];
    [self addChildViewController:nav];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
